package bit.springaopdemo.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
//@Component
public class AspectDemo1  {

    //下面的注解加上方法组成的整体叫做切面
    @Around("execution(* bit.springaopdemo.controller.*.*(..))")//切点表达式
    public Object timeRecord(ProceedingJoinPoint joinPoint) throws Throwable {//通知
        long start = System.currentTimeMillis();
        Object result = joinPoint.proceed();//还是存在耦合关系
        long end = System.currentTimeMillis();
        log.info(joinPoint.getSignature().toString()+"耗时："+(end-start)+"ms");
        return result;//这个result是返回给前端显示的
    }


}
